package com.linkelee.manage.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 地址转发拦截器
 * @author lsl
 * @since 2019-04-10
 */

@Slf4j
public class UrlInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response, Object handler)
            throws Exception {
        String url = request.getRequestURI();
        if(request.getRequestURI().startsWith("/eafbi")){
            log.info("拦截url进行转发:"+url);
            log.info("转发url:"+url.replace("/eafbi",""));
            request.getRequestDispatcher(url.replace("/eafbi",""))
                    .forward(request,response);
            return false;
        }
        return true;
    }
}
